package chatclient.applets.note;

import chatclient.tools.NoteContainer;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;


class ImagePart implements NotePart{

    BufferedImage image;
    ImageObserver observer;

    public ImagePart(BufferedImage image, ImageObserver observer) {

        this.image = image;
        this.observer = observer;
    }

    @Override
    public int getWidth() {
        return image.getWidth(observer);
    }

    @Override
    public int getAscent() {
        return image.getHeight(observer);
    }

    @Override
    public void paint(NoteContainer notecontainer, Note note, Graphics g, int i, int j, String s, Color color,
            Double double1) {
        
        g.drawImage(image, i, j, observer);
    }
     
    @Override
    public String toString() {
        return "<image>";
    }

    @Override
    public boolean isWhiteSpace() {
        return false;
    }

    @Override
    public boolean hasEol() {
        return false;
    }

    @Override
    public NotePart breakAtWidth(int i, boolean flag, LinePart linepart) {
        if (flag) {
            linepart.add(this, true);
            return null;
        } else {
            return this;
        }
    }

    @Override
    public int getDescent() {
        return 0;
    }

    @Override
    public int getHeight() {
        return getLeading() + getAscent() + getDescent();
    }

    @Override
    public int getLeading() {
        return 0;
    }

    @Override
    public int getMaxAscent() {
        return getAscent();
    }

    @Override
    public int getMaxDescent() {
        return getDescent();
    }

}
